package com.itheima.controller;

import com.itheima.service.db.OptionSoulService;
import com.itheima.service.db.QuestionForSoulService;
import com.itheima.service.db.TopicService;
import com.itheima.service.db.UserTopicService;
import com.itheima.vo.*;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@RequiredArgsConstructor
public class TestSoulController {

    private final TopicService topicService;

    private final OptionSoulService optionSoulService;

    private final QuestionForSoulService questionForSoulService;

    private final UserTopicService userTopicService;

    @GetMapping("findTopics")
    public List<TopicVo> findTopics(){
        return topicService.findTopics();
    }


    @GetMapping("findOptions")
    public List<OptionsVo> findOptions() {
        return optionSoulService.findOptions();
    }

    @GetMapping("/findQuestions")
    public List<QuestionsVo> findQuestions(){
        return questionForSoulService.findQuestions();
    }

    @GetMapping("/findScoreById")
    public Integer findScoreById(@RequestParam("questionId") String questionId, @RequestParam("optionId") String optionId){
        return optionSoulService.findScoreById(questionId,optionId);
    }

    @PostMapping("/submit")
    public Long submit(@RequestBody AnswersVo answersVo){
        return  userTopicService.submit(answersVo);
    }

    @GetMapping("/queryResult")
    public ReportVo queryResult(@RequestParam("id") Long id){
        return userTopicService.queryResult(id);
    }
}
